import java.util.Scanner;

public class PalindromeMaker {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String input = scanner.nextLine();

        String result = makePalindrome(input);
        System.out.println("最小回文串为：" + result);
    }

    public static String makePalindrome(String s) {
        int n = s.length();
        for (int i = 0; i < n; i++) {
            if (isPalindrome(s.substring(i))) {
                return new StringBuilder(s.substring(0, i)).reverse().toString() + s;
            }
        }
        return "";
    }

    public static boolean isPalindrome(String s) {
        int left = 0, right = s.length() - 1;
        while (left < right) {
            if (s.charAt(left) != s.charAt(right)) return false;
            left++;
            right--;
        }
        return true;
    }
}
